(function(){
'use strict';

angular.module('controllers.faultLocation.pbossOm')
  .controller('5ICCIDController', ICCIDController);

function ICCIDController($scope, pbossOmServer, reponsestate, requeststate, COREDATA) {
  $scope.shoumun = 0;
  $scope.ICCID=requeststate.ICCID;
  pbossOmServer.CCID(
    function(res) {
      if (res.state === '10000') {
        $scope.items = res.data.pageData;
        Echarts(dataProvinceClassification($scope.items));
      }
    }
  );
  //查询条件参数数据类型
  $scope.provinces = COREDATA.PROVINCES;
  $scope.date = {};
  $scope.date.startTime = new Date();
  $scope.date.endTime = new Date();
  $scope.queryAllChannel = function() {
    $scope.shoumun =$scope.shoumun === 1 ?  0 : 1;
    if ($scope.shoumun === 0) {
      pbossOmServer.CCID(
        function(res) {
          if (res.state === '10000') {
            $scope.items = res.data.pageData;
            Echarts(dataProvinceClassification($scope.items));
          }
        }
      );
      //Echarts();
    }
  };

  function dataProvinceClassification(data) {
    var params = {
      portfolio: [],
      portfolios: []
    };
    angular.forEach(data, function(key) {
      params.portfolio.push(key.provinceName);
      params.portfolios.push(key.utilization);
    });
    return params;
  }

  var customerEchart = echarts.init(document.getElementById('main'));

  function Echarts(params) {

    var dataStyle = {
      normal: {
        label: {
          show: true,
          position: 'top',
          formatter: '{c}%'
        }
      }
    };

    var option = {
      tooltip: {
        trigger: 'axis',
        axisPointer: { // 坐标轴指示器，坐标轴触发有效
          type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
        }
      },
      calculable: true,
      xAxis: [{
        type: 'category',
        //  boundaryGap : false,
        data: params.portfolio

      }],
      yAxis: [{
        type: 'value',
        axisLabel: {
          formatter: '{value} %'
        },
      }],
      series: [{
        type: 'bar',
        stack: '总量',
        data: params.portfolios,
        itemStyle: dataStyle,
        barMaxWidth: 13
      }]
    };
    customerEchart.setOption(option);

  }

}

ICCIDController.$inject = ['$scope', 'pbossOmServer', 'reponsestate', 'requeststate', 'COREDATA'];
})();